package project2011;
import java.util.*;
/**
 * A UserList stores users in an ArrayList called userList
 * @author Antone Gonzalez
 */
public class UserList {

    /**
     * constructor for UserList
     */
    public UserList()
    {
        userList = new ArrayList<User>();
    }
    
    /**
     * finds and returns a user based on the passed in name
     * @param name the name of the user to find
     * @return the user with the passed in name
     */
    public User findUser(String name)
    {
        for(User x: userList)
        {
            if(x.getName().equals(name))
            {
                return x;
            }
        }
        
        return null;
    }
    
    /**
     * returns a string with all contents of this userlist
     * @return a string with all contents of this userlist
     */
    public String print()
    {
        String result = new String();
        for(User x: userList)
        {
            result += x.print();
        }
        return result;
    }
    
    /**
     * adds a user to userlist
     * @param toAdd the user to add to userlist
     */
    public void addUser(User toAdd)
    {
        userList.add(toAdd);
    }
    
    private ArrayList<User> userList;
}
